<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>用户封停</title>
    <script src="/jquery/jquery-3.2.1.min.js"></script>
    <script src="/layui/layui.js"></script>
    <link rel="stylesheet" href="/layui/css/layui.css"/>
    <style>
        .div_width{
            width: 400px;
        }
        .btn{
            position: absolute;
            right: 30px;
            bottom: 30px;
        }
    </style>
</head>
<body>
    <form class="layui-form" lay-filter="formTest" action="" style="margin-top: 40px">
        <div class="layui-form-item div_width">
            <label class="layui-form-label">用户账号</label>
            <div class="layui-input-block">
                <input type="text" id="account" disabled="disabled" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
                <input type="hidden" name="account"/>
                <input type="hidden" name="id"/>
            </div>
        </div>
        <div class="layui-form-item div_width">
            <label class="layui-form-label">封停天数</label>
            <div class="layui-input-block">
                <select name="city" lay-verify="filter" lay-filter="filter">
                    <option value="7">7天</option>
                    <option value="10">10天</option>
                    <option value="15">15天</option>
                    <option value="30">30天</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item div_width">
            <label class="layui-form-label">封停原因</label>
            <div class="layui-input-block">
                <textarea id="desc" rows="3" cols="20" placeholder="请输入封停原因" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="btn">
            <button onclick="determine()" type="button" class="layui-btn layui-btn-xs layui-btn-normal">确定</button>
            <button onclick="cancel()" class="layui-btn layui-btn-xs layui-btn-warm">取消</button>
        </div>
    </form>

</body>
<script>
    var form;
    var $;
    var table;
    var layer;
    var upload;
    var laydate;
    var day = 7;
    layui.use(['laydate','form','jquery','table','layer','upload'],function() {
        form = layui.form;
        laydate = layui.laydate;
        $ = layui.jquery;
        table = layui.table;
        layer = layui.layer;
        upload = layui.upload;

        form.on('select(filter)', function(data){
            day = parseInt(data.value); //得到被选中的值
        });
    });
    function determine() {
        var account = $('input[name = account]').val();
        var id = $('input[name = id]').val();
        var desc = $('#desc').val();
        function getTime(){
            var curDate = new Date();
            var date=new Date(curDate.setDate(curDate.getDate()+day));
            var year = date.getFullYear();//获取年
            var month = date.getMonth()+1;//获取月
            var today = date.getDate(); //获取当前日(1-31)
            var hour = date.getHours();//获取时
            var minute = date.getMinutes();//获取分
            var second = date.getSeconds();//获取秒
            var time = year+"-"+month+"-"+today+" "+hour+":"+minute+":"+second;
            return time;
        }
        $.ajax({
            url:'/UserList/addClosure',
            dataType:'json',
            data:{
                "userId":id,"type":2,"reason":desc,"days":day,"endDate":getTime()
            },
            success:function (data) {
                if(data.data){
                    parent.start();
                    var layer = parent.layer;
                    layer.close(layer.index);
                    layer.msg("操作成功");
                }
            }
        });
    }
    function cancel() {
        var layer = parent.layer;
        layer.close(layer.index);
    }
</script>
</html>